91. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2024-03-04 14:38:48 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

91.1 Files compared

#LocationFileLast Modified
1/Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme v4.0.7/app/code/Smartwave/Porto/HelperData.php2023-10-25 04:39:44 +0000
2/Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme v4.0.8/app/code/Smartwave/Porto/HelperData.php2024-01-30 13:36:44 +0000

91.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged2444
Changed00
Inserted18
Removed00

91.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

91.4 Active regular expressions

No regular expressions were active.

91.5 Comparison detail

1 <?php 1 <?php
2 /** 2 /**
3  * Copyright © 2015 Magento. All rights reserved. 3  * Copyright © 2015 Magento. All rights reserved.
4  * See COPYING.txt for license details. 4  * See COPYING.txt for license details.
5  */ 5  */
6 namespace Smartwave\Porto\Helper; 6 namespace Smartwave\Porto\Helper;
7  7 
8 use Magento\Framework\Registry; 8 use Magento\Framework\Registry;
9  9 
10 class Data extends \Magento\Framework\App\Helper\AbstractHelper 10 class Data extends \Magento\Framework\App\Helper\AbstractHelper
11 { 11 {
12  12 
13     protected $_objectManager; 13     protected $_objectManager;
14     private $_registry; 14     private $_registry;
15     protected $_filterProvider; 15     protected $_filterProvider;
16     private $_checkedPurchaseCode; 16     private $_checkedPurchaseCode;
17     private $_messageManager; 17     private $_messageManager;
18     protected $_configFactory; 18     protected $_configFactory;
19     protected $_storeManager; 19     protected $_storeManager;
20  20 
21     public function __construct( 21     public function __construct(
22         \Magento\Framework\App\Helper\Context $context, 22         \Magento\Framework\App\Helper\Context $context,
23         \Magento\Framework\ObjectManagerInterface $objectManager, 23         \Magento\Framework\ObjectManagerInterface $objectManager,
24         \Magento\Store\Model\StoreManagerInterface $storeManager, 24         \Magento\Store\Model\StoreManagerInterface $storeManager,
25         \Magento\Cms\Model\Template\FilterProvider $filterProvider, 25         \Magento\Cms\Model\Template\FilterProvider $filterProvider,
26         \Magento\Framework\Message\ManagerInterface $messageManager, 26         \Magento\Framework\Message\ManagerInterface $messageManager,
27         \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory, 27         \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory,
28         Registry $registry 28         Registry $registry
29     ) { 29     ) {
30         $this->_storeManager = $storeManager; 30         $this->_storeManager = $storeManager;
31         $this->_objectManager = $objectManager; 31         $this->_objectManager = $objectManager;
32         $this->_filterProvider = $filterProvider; 32         $this->_filterProvider = $filterProvider;
33         $this->_registry = $registry; 33         $this->_registry = $registry;
34         $this->_messageManager = $messageManager; 34         $this->_messageManager = $messageManager;
35         $this->_configFactory = $configFactory; 35         $this->_configFactory = $configFactory;
36  36 
37         parent::__construct($context); 37         parent::__construct($context);
38     } 38     }
39     public function checkPurchaseCode($save = false) { 39     public function checkPurchaseCode($save = false) {
40         if($this->isLocalhost()){ 40         if($this->isLocalhost()){
41             return "localhost"; 41             return "localhost";
42         } 42         }
43         if(!$this->_checkedPurchaseCode){ 43         if(!$this->_checkedPurchaseCode){
44             $code = $this->scopeConfig->getValue('porto_license/general/purchase_code')?$this->scopeConfig->getValue('porto_license/general/purchase_code'):''; 44             $code = $this->scopeConfig->getValue('porto_license/general/purchase_code')?$this->scopeConfig->getValue('porto_license/general/purchase_code'):'';
45             $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm')?$this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'):''; 45             $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm')?$this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'):'';
46  46 
47             if($save) { 47             if($save) {
48                 $site_url = $this->scopeConfig->getValue('web/unsecure/base_url'); 48                 $site_url = $this->scopeConfig->getValue('web/unsecure/base_url');
49                 $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url)); 49                 $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url));
50                 if(strpos($domain, "/")) 50                 if(strpos($domain, "/"))
51                     $domain = substr($domain, 0, strpos($domain, "/")); 51                     $domain = substr($domain, 0, strpos($domain, "/"));
52                 if(!$code || base64_encode($code) != $code_confirm) { 52                 if(!$code || base64_encode($code) != $code_confirm) {
53                     $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove"); 53                     $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove");
54                 } 54                 }
55                 if($code) { 55                 if($code) {
56                     $result = $this->curlPurchaseCode($code, $domain, "add"); 56                     $result = $this->curlPurchaseCode($code, $domain, "add");
57                     if(!$result || $result['result'] == 0) { 57                     if(!$result || $result['result'] == 0) {
58                         $this->_checkedPurchaseCode = ""; 58                         $this->_checkedPurchaseCode = "";
59                         $code_confirm = ""; 59                         $code_confirm = "";
60                         $this->_messageManager->getMessages(true); 60                         $this->_messageManager->getMessages(true);
61                         $this->_messageManager->addWarning(__('Purchase code is not valid!')); 61                         $this->_messageManager->addWarning(__('Purchase code is not valid!'));
62                     } else if($result['result'] == 1) { 62                     } else if($result['result'] == 1) {
63                         $code_confirm = base64_encode($code); 63                         $code_confirm = base64_encode($code);
64                         $this->_checkedPurchaseCode = "verified"; 64                         $this->_checkedPurchaseCode = "verified";
65                     } else { 65                     } else {
66                         $this->_checkedPurchaseCode = ""; 66                         $this->_checkedPurchaseCode = "";
67                         $code_confirm = ""; 67                         $code_confirm = "";
68                         $this->_messageManager->getMessages(true); 68                         $this->_messageManager->getMessages(true);
69                         $this->_messageManager->addWarning(__($result['message'])); 69                         $this->_messageManager->addWarning(__($result['message']));
70                     } 70                     }
71                 } else { 71                 } else {
72                     $code_confirm = ""; 72                     $code_confirm = "";
73                     $this->_checkedPurchaseCode = ""; 73                     $this->_checkedPurchaseCode = "";
74                 } 74                 }
75                 $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0); 75                 $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0);
76             } else { 76             } else {
77                 if($code && $code_confirm && base64_encode($code) == $code_confirm) 77                 if($code && $code_confirm && base64_encode($code) == $code_confirm)
78                     $this->_checkedPurchaseCode = "verified"; 78                     $this->_checkedPurchaseCode = "verified";
79             } 79             }
80         } 80         }
81  81 
82         return $this->_checkedPurchaseCode; 82         return $this->_checkedPurchaseCode;
83     } 83     }
84     public function curlPurchaseCode($code, $domain, $act) { 84     public function curlPurchaseCode($code, $domain, $act) {
85         $ch = curl_init(); 85         $ch = curl_init();
86  86 
87         // Set cURL options 87         // Set cURL options
88         curl_setopt($ch, CURLOPT_URL, "https://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act"); 88         curl_setopt($ch, CURLOPT_URL, "https://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act");
89         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 89         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
90         curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY'); 90         curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY');
91  91 
92         // Decode returned JSON 92         // Decode returned JSON
93         $result = json_decode( curl_exec($ch) , true ); 93         $result = json_decode( curl_exec($ch) , true );
94         return $result; 94         return $result;
95     } 95     }
96     public function isLocalhost() { 96     public function isLocalhost() {
97         $whitelist = array( 97         $whitelist = array(
98             '127.0.0.1', 98             '127.0.0.1',
99             '::1' 99             '::1'
100         ); 100         );
101  101 
102         return in_array($_SERVER['REMOTE_ADDR'], $whitelist); 102         return in_array($_SERVER['REMOTE_ADDR'], $whitelist);
103     } 103     }
104     public function isAdmin() { 104     public function isAdmin() {
105         $om = \Magento\Framework\App\ObjectManager::getInstance(); 105         $om = \Magento\Framework\App\ObjectManager::getInstance();
106         $app_state = $om->get('\Magento\Framework\App\State'); 106         $app_state = $om->get('\Magento\Framework\App\State');
107         $area_code = $app_state->getAreaCode(); 107         $area_code = $app_state->getAreaCode();
108         if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) 108         if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)
109         { 109         {
110             return true; 110             return true;
111         } 111         }
112         else 112         else
113         { 113         {
114             return false; 114             return false;
115         } 115         }
116     } 116     }
117     public function getBaseUrl() 117     public function getBaseUrl()
118     { 118     {
119         return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); 119         return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
120     } 120     }
121     public function getBaseLinkUrl() 121     public function getBaseLinkUrl()
122     { 122     {
123         return $this->_storeManager->getStore()->getBaseUrl(); 123         return $this->_storeManager->getStore()->getBaseUrl();
124     } 124     }
125     public function getConfig($config_path) 125     public function getConfig($config_path)
126     { 126     {
127         return $this->scopeConfig->getValue( 127         return $this->scopeConfig->getValue(
128             $config_path, 128             $config_path,
129             \Magento\Store\Model\ScopeInterface::SCOPE_STORE 129             \Magento\Store\Model\ScopeInterface::SCOPE_STORE
130         ); 130         );
131     } 131     }
132     public function getModel($model) { 132     public function getModel($model) {
133         return $this->_objectManager->create($model); 133         return $this->_objectManager->create($model);
134     } 134     }
135     public function getCurrentStore() { 135     public function getCurrentStore() {
136         return $this->_storeManager->getStore(); 136         return $this->_storeManager->getStore();
137     } 137     }
    138     public function getCurrentProduct()
    139     {
    140         return $this->_registry->registry('current_product');
    141     }
    142     public function getCurrentCategory()
    143     {
    144         return $this->_registry->registry('current_category');
    145     }
138     public function filterContent($content) { 146     public function filterContent($content) {
139         return $this->_filterProvider->getPageFilter()->filter($content); 147         return $this->_filterProvider->getPageFilter()->filter($content);
140     } 148     }
141     public function getCategoryProductIds($current_category) { 149     public function getCategoryProductIds($current_category) {
142         $category_products = $current_category->getProductCollection() 150         $category_products = $current_category->getProductCollection()
143             ->addAttributeToSelect('*') 151             ->addAttributeToSelect('*')
144             ->addAttributeToSort('position','asc'); 152             ->addAttributeToSort('position','asc');
145         $cat_prod_ids = $category_products->getAllIds(); 153         $cat_prod_ids = $category_products->getAllIds();
146  154 
147         return $cat_prod_ids; 155         return $cat_prod_ids;
148     } 156     }
149     public function getPercentage(\Magento\Catalog\Model\Product $product) 157     public function getPercentage(\Magento\Catalog\Model\Product $product)
150     { 158     {
151         $baseprice = 0; 159         $baseprice = 0;
152         $finalprice = 0; 160         $finalprice = 0;
153         $percentage = 0; 161         $percentage = 0;
154  162 
155         if ($product->getTypeId() == 'configurable') { 163         if ($product->getTypeId() == 'configurable') {
156             $baseprice = $product->getPriceInfo() 164             $baseprice = $product->getPriceInfo()
157                 ->getPrice('regular_price') 165                 ->getPrice('regular_price')
158                 ->getValue(); 166                 ->getValue();
159  167 
160             $finalprice = $product->getPriceInfo() 168             $finalprice = $product->getPriceInfo()
161                 ->getPrice('final_price') 169                 ->getPrice('final_price')
162                 ->getValue(); 170                 ->getValue();
163         } else { 171         } else {
164             $baseprice = $product->getPrice(); 172             $baseprice = $product->getPrice();
165             $finalprice = $product->getFinalPrice(); 173             $finalprice = $product->getFinalPrice();
166         } 174         }
167  175 
168         $specialfromdate = $product->getSpecialFromDate(); 176         $specialfromdate = $product->getSpecialFromDate();
169         $specialtodate = $product->getSpecialToDate(); 177         $specialtodate = $product->getSpecialToDate();
170         $today = time(); 178         $today = time();
171  179 
172         if ($finalprice < $baseprice) { 180         if ($finalprice < $baseprice) {
173             if((is_null($specialfromdate) && is_null($specialtodate)) || ($today >= strtotime($specialfromdate) && is_null($specialtodate)) || ($today <= strtotime($specialtodate) && is_null($specialfromdate)) || ($today >= strtotime($specialfromdate) && $today <= strtotime($specialtodate))){ 181             if((is_null($specialfromdate) && is_null($specialtodate)) || ($today >= strtotime($specialfromdate) && is_null($specialtodate)) || ($today <= strtotime($specialtodate) && is_null($specialfromdate)) || ($today >= strtotime($specialfromdate) && $today <= strtotime($specialtodate))){
174               $percentage = round(-100 * (1 - ($finalprice / $baseprice))); 182               $percentage = round(-100 * (1 - ($finalprice / $baseprice)));
175             } 183             }
176         } 184         }
177  185 
178         return $percentage; 186         return $percentage;
179     } 187     }
180     public function getPrevProduct($product) { 188     public function getPrevProduct($product) {
181         $current_category = $product->getCategory(); 189         $current_category = $product->getCategory();
182         if(!$current_category) { 190         if(!$current_category) {
183             foreach($product->getCategoryCollection() as $parent_cat) { 191             foreach($product->getCategoryCollection() as $parent_cat) {
184                 $current_category = $parent_cat; 192                 $current_category = $parent_cat;
185             } 193             }
186         } 194         }
187         if(!$current_category) 195         if(!$current_category)
188             return false; 196             return false;
189         $cat_prod_ids = $this->getCategoryProductIds($current_category); 197         $cat_prod_ids = $this->getCategoryProductIds($current_category);
190         $_pos = array_search($product->getId(), $cat_prod_ids); 198         $_pos = array_search($product->getId(), $cat_prod_ids);
191         if (isset($cat_prod_ids[$_pos - 1])) { 199         if (isset($cat_prod_ids[$_pos - 1])) {
192             $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]); 200             $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]);
193             return $prev_product; 201             return $prev_product;
194         } 202         }
195         return false; 203         return false;
196     } 204     }
197     public function getNextProduct($product) { 205     public function getNextProduct($product) {
198         $current_category = $product->getCategory(); 206         $current_category = $product->getCategory();
199         if(!$current_category) { 207         if(!$current_category) {
200             foreach($product->getCategoryCollection() as $parent_cat) { 208             foreach($product->getCategoryCollection() as $parent_cat) {
201                 $current_category = $parent_cat; 209                 $current_category = $parent_cat;
202             } 210             }
203         } 211         }
204         if(!$current_category) 212         if(!$current_category)
205             return false; 213             return false;
206         $cat_prod_ids = $this->getCategoryProductIds($current_category); 214         $cat_prod_ids = $this->getCategoryProductIds($current_category);
207         $_pos = array_search($product->getId(), $cat_prod_ids); 215         $_pos = array_search($product->getId(), $cat_prod_ids);
208         if (isset($cat_prod_ids[$_pos + 1])) { 216         if (isset($cat_prod_ids[$_pos + 1])) {
209             $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]); 217             $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]);
210             return $next_product; 218             return $next_product;
211         } 219         }
212         return false; 220         return false;
213     } 221     }
214  222 
215     public function getMasonryItemClass($arr) { 223     public function getMasonryItemClass($arr) {
216         $item_class = ""; 224         $item_class = "";
217         foreach ($arr as $key => $value) { 225         foreach ($arr as $key => $value) {
218             $item_class .= ' ' . $key . '-' . $value; 226             $item_class .= ' ' . $key . '-' . $value;
219         } 227         }
220         return $item_class; 228         return $item_class;
221     } 229     }
222 } 230 }